{% extends "base.html" %}
{% from "macros/macro_pagination.html" import render_pagination %}

{% block title %}
    短剧
{% endblock %}

{% block page_title %}
    短剧列表
{% endblock %}


{% block header_actions %}
    <div class="page-actions">
        <a href="{{ url_for('album_info.create') }}" class="btn btn-primary">
            <i class="fa fa-plus"></i> 新建
        </a>
    </div>
{% endblock %}

{% block body %}

    <!-- 搜索区域 -->
    <form id="queryForm" method="post" action="{{ url_for('album_info.page') }}">
        {{ form.csrf_token }}
        <div class="search-container">
            <div class="search-form">
                <div class="condition">
                    <label>{{ form.title.label }}</label>
                    <div class="filter-input">
                        {{ form.title() }}
                    </div>
                </div>
                <div class="condition">
                    <label>{{ form.release_year.label }}</label>
                    <div class="filter-input">
                        {{ form.release_year(class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500") }}
                    </div>
                </div>
                <div class="condition">
                    <label>{{ form.album_status.label }}</label>
                    <div class="filter-input">
                        {{ form.album_status() }}
                    </div>
                </div>
            </div>
            <div class="condition-more">
                <div class="condition" style="margin-right: 0;">
                    <button class="search-button" type="submit">
                        <i class="fa fa-search"></i>查询
                    </button>
                    <button class="reset-button" type="button" onclick="clearForm()">
                        <i class="fas fa-times"></i>重置
                    </button>
                </div>
            </div>
        </div>
    </form>
    <!-- 数据列表 -->
    <div class="data-table-container">
        <table class="data-table">
            <thead>
            <tr>
                <th>ID</th>
                <th>标题</th>
                <th>总集数</th>
                <th>发行年份</th>
                <th>更新状态</th>
                <th>抖音短剧ID</th>
                <th>当前版本</th>
                <th>上线版本</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {% for item in pagination.items %}
                <tr>
                    <td>{{ item.get('id') }}</td>
                    <td>{{ item.get('title') }}</td>
                    <td>{{ item.get('seq_num') }}</td>
                    <td>{{ item.get('release_year') }}</td>
                    <td>{{ item.get('album_status_name') }}</td>
                    <td>{{ item.get('dy_album_id') if item.get('dy_album_id') else '' }}</td>
                    <td>{{ item.get('current_dy_version') }}</td>
                    <td>{{ item.get('online_dy_version') }}</td>
                    <td>{{ item.get('create_time') }}</td>
                    <td class="action-buttons">
                        <a class="action-btn view-btn" target="_blank"
                           href="{{ url_for('album_info.index',id=item.get('id')) }}">
                            查看
                        </a>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
    <!-- 分页控件 -->
    {{ render_pagination(pagination, 'album_info.page', form=form) }}
{% endblock %}